package com.yungu.swift.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * @author cuixiuyin
 * @Description:
 * @date 2018/11/12
 */
public class ParamUtil {
    /**
     * @param params
     * @return boolean
     * @Description 参数是否合法
     * @author cuixiuyin
     * @date 2018/11/12 21:05
     */
    public static boolean isIllegal(Object... params) {
        for (Object param : params) {
            if (param instanceof String) {
                if (StringUtils.isBlank((String) param)) {
                    return true;
                }
            } else {
                if (param == null) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * @param t
     * @param defaultValue
     * @return T
     * @Description null 2 default
     * @author cuixiuyin
     * @date 2018/11/12 21:05
     */
    public static <T> T defaultIfNull(T t, T defaultValue) {
        return t == null ? defaultValue : t;
    }
}
